package com.yn.xgame.logic;

import com.yn.xgame.game.RoomPlayer;
import com.yn.xgame.game.message.SimplePlayer;
import com.yn.xgame.logic.player.BackPackModule;
import com.yn.xgame.logic.player.UserBankModule;
import com.yn.xgame.logic.player.UserMessageModule;
import com.yn.xgame.pb.GateClientProto;

/**
 * GamePlayer
 * Created by wangboo on 17/7/13.
 */
public class GamePlayer {
    private String gateTopic;
    private String logicTopic;
    private String centerTopic;
    private String game;
    private String gameTopic;
	private long sessionId;
	private int roomId;
    private String tableId;
    private String token;

	private int userId;
	private int userCode;
	private String userNickName;
	private String userName;
	private String userStatus;

	private String bankPwd;
	private String Pwd;
	private int userHorn;
	private int userIcon;
	private int userVipLevel;
	private int userLevel;
	private int userExp;
	private String userWalletGold;
	private String userBankGold;
    private String userTel;

	private long lastLoginTime;
    private long lastLeaveTime;
    
    //功能块
    private BackPackModule backPackModule;
    private UserMessageModule userMessageModule;
    private UserBankModule userBankModule;

    public String getGateTopic() {
        return gateTopic;
    }

    public void setGateTopic(String gateTopic) {
        this.gateTopic = gateTopic;
    }

    public String getLogicTopic() {
        return logicTopic;
    }

    public void setLogicTopic(String logicTopic) {
        this.logicTopic = logicTopic;
    }

    public String getUserStatus() {
		return userStatus;
	}

	public void setUserStatus(String userStatus) {
		this.userStatus = userStatus;
	}

	public String getUserTel() {
    	return userTel;
    }
    public void setUserTel(String userTel) {
    	this.userTel = userTel;
    }
	public UserBankModule getUserBankModule() {
		return userBankModule;
	}
	public void setUserBankModule(UserBankModule userBankModule) {
		this.userBankModule = userBankModule;
	}
	public BackPackModule getBackPackModule() {
		return backPackModule;
	}
	public void setBackPackModule(BackPackModule backPackModule) {
		this.backPackModule = backPackModule;
	}
	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}
	public UserMessageModule getUserMessageModule() {
		return userMessageModule;
	}
	public void setUserMessageModule(UserMessageModule userMessageModule) {
		this.userMessageModule = userMessageModule;
	}
	public long getSessionId() {
		return sessionId;
	}
	public void setSessionId(long sessionId) {
		this.sessionId = sessionId;
	}
	public int getUserId() {
		return userId;
	}
	public void setUserId(int userId) {
		this.userId = userId;
	}
	public int getUserCode() {
		return userCode;
	}
	public void setUserCode(int userCode) {
		this.userCode = userCode;
	}
	public String getUserNickName() {
		return userNickName;
	}
	public void setUserNickName(String userNickName) {
		this.userNickName = userNickName;
	}
	public String getBankPwd() {
		return bankPwd;
	}
	public void setBankPwd(String bankPwd) {
		this.bankPwd = bankPwd;
	}
	public String getPwd() {
		return Pwd;
	}
	public void setPwd(String pwd) {
		Pwd = pwd;
	}
	public int getUserHorn() {
		return userHorn;
	}
	public void setUserHorn(int userHorn) {
		this.userHorn = userHorn;
	}
	public int getUserIcon() {
		return userIcon;
	}
	public void setUserIcon(int userIcon) {
		this.userIcon = userIcon;
	}
	public int getUserVipLevel() {
		return userVipLevel;
	}
	public void setUserVipLevel(int userVipLevel) {
		this.userVipLevel = userVipLevel;
	}
	public int getUserLevel() {
		return userLevel;
	}
	public void setUserLevel(int userLevel) {
		this.userLevel = userLevel;
	}
	public int getUserExp() {
		return userExp;
	}
	public void setUserExp(int userExp) {
		this.userExp = userExp;
	}
	public String getUserWalletGold() {
		return userWalletGold;
	}
	public void setUserWalletGold(String userWalletGold) {
		this.userWalletGold = userWalletGold;
	}
	public String getUserBankGold() {
		return userBankGold;
	}
	public void setUserBankGold(String userBankGold) {
		this.userBankGold = userBankGold;
	}
	public long getLastLoginTime() {
		return lastLoginTime;
	}
	public void setLastLoginTime(long lastLoginTime) {
		this.lastLoginTime = lastLoginTime;
	}
	public long getLastLeaveTime() {
		return lastLeaveTime;
	}
	public void setLastLeaveTime(long lastLeaveTime) {
		this.lastLeaveTime = lastLeaveTime;
	}

    public String getCenterTopic() {
        return centerTopic;
    }

    public void setCenterTopic(String centerTopic) {
        this.centerTopic = centerTopic;
    }

    public String getGame() {
        return game;
    }

    public void setGame(String game) {
        this.game = game;
    }

    public String getGameTopic() {
        return gameTopic;
    }

    public void setGameTopic(String gameTopic) {
        this.gameTopic = gameTopic;
    }

    public int getRoomId() {
        return roomId;
    }

    public void setRoomId(int roomId) {
        this.roomId = roomId;
    }

	public String getTableId() {
		return tableId;
	}

	public void setTableId(String tableId) {
		this.tableId = tableId;
	}
	
	public String getToken() {
		return token;
	}

	public void setToken(String token) {
		this.token = token;
	}

	@Override
	public String toString() {
		return "GamePlayer [sessionId=" + sessionId + ", userId=" + userId + ", userCode=" + userCode
				+ ", userNickName=" + userNickName + ", bankPwd=" + bankPwd + ", Pwd=" + Pwd + ", userHorn=" + userHorn
				+ ", userIcon=" + userIcon + ", userVipLevel=" + userVipLevel + ", userLevel=" + userLevel
				+ ", userExp=" + userExp + ", userWalletGold=" + userWalletGold + ", userBankGold=" + userBankGold
				+ ", userTel=" + userTel + ", lastLoginTime=" + lastLoginTime + ", lastLeaveTime=" + lastLeaveTime
				+ ", backPackModule=" + backPackModule + ", userMessageModule=" + userMessageModule
				+ ", userBankModule=" + userBankModule + "]";
	}
	public GamePlayer(long sid) {
    	this.sessionId=sid;
    }

    public void handleUserLeave() {
    	
    }
    
    public void respToClient(String fromGateTopic, GateClientProto.G2CMessage msg) {
		LogicApp.mqClient.sendClient(fromGateTopic, sessionId, msg);
	}

	public RoomPlayer toRoomPlayer() {
		RoomPlayer p = new RoomPlayer(sessionId, userId);
		/**
		 * protected String nickName;
		 @JSONField(name = "uwg")
		 protected String userWalletGold;
		 protected int userHorn;
		 protected int userIcon;
		 protected int userVipLevel;
		 protected int userLevel;
		 protected int userExp;
		 */
		p.gateTopic = gateTopic;
		p.logicTopic = logicTopic;
		p.nickName = userNickName;
		p.userWalletGold = Long.parseLong(userWalletGold);
		p.userHorn = userHorn;
		p.userIcon = userIcon;
		p.userVipLevel = userVipLevel;
		p.userLevel = userLevel;
		p.userExp = userExp;
		return p;
	}

	public SimplePlayer toSimplePlayer() {
		SimplePlayer p = new SimplePlayer();
		p.logic = this.logicTopic;
		p.name = this.userNickName;
		p.sid = this.sessionId;
		p.uid = this.userId;
		return p;
	}

	public void dumpToDB() {
    	// 保存到服务器
		LogicApp.dbServer.applyFunc1(this, LogicApp.dbServer.dumpHander::dump);
	}
}
